﻿using System;
using System.Collections.Generic;
using System.Linq;
using Styx;
using Styx.Common;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;

namespace TuanHA_Combat_Routine
{
    public partial class Classname
    {
        #region BuffBurst

        //private static readonly HashSet<int> BuffBurstHS = new HashSet<int>
        //    {
        //        51271, // "Pillar of Frost",
        //        49016, //"Unholy Frenzy",
        //        102560, // "Incarnation: Chosen of Elune",
        //        124974, //"Nature's Vigil",
        //        106952, //"Berserk ",
        //        19574, //"Bestial Wrath",
        //        3045, //"Rapid Fire",
        //        12472, //"Icy Veins",
        //        //"Time Warp",
        //        //"Tigereye Brew",
        //        31884, //"Avenging Wrath",
        //        105809, //"Holy Avenger",
        //        86698, //"Guardian of Ancient Kings",
        //        86669, //"Guardian of Ancient Kings",
        //        51713, //"Shadow Dance",
        //        51690, // "Killing Spree",
        //        13750, //Adrenaline Rush
        //        114049, // "Ascendance",
        //        114051, // "Ascendance",
        //        //"Bloodlust",
        //        113858, //"Dark Soul: Instability",
        //        1719, //"Recklessness",
        //        114207, //"Skull Banner",
        //    };
        private static readonly HashSet<int> BuffBurstHS = new HashSet<int> { 
            0x1a436, 0x3004, 0x1da7f, 0xc847, 0xbf78, 0x190a0, 0x1e82e, 0x1a1c8, 0x4c76, 0xbe5, 0x30b8, 0x7c8c, 0x19d51, 0x152aa, 0x1528d, 0xca01, 
            0xc9ea, 0x35b6, 0x1bd81, 0x1bd83, 0x1bcc2, 0x6b7, 0x1be1f
         };

        private static bool BuffBurst(WoWUnit target)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && BuffBurstHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region BuffEnrage

        //private static readonly HashSet<int> BuffEnrageHS = new HashSet<int>
        //    {
        //        13046,//"Enraged",
        //        18499,//"Berserker Rage",
        //        55694,//"Enraged Regeneratione",
        //    };
        private static readonly HashSet<int> BuffEnrageHS = new HashSet<int> { 0x32f6, 0x4843, 0xd98e };
        private static bool BuffEnrage(WoWUnit target)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(delegate(AuraCacheClass aura)
            {
                if (aura.AuraCacheUnit != target.Guid)
                {
                    return false;
                }
                if (!BuffEnrageHS.Contains(aura.AuraCacheId))
                {
                    return (aura.AuraCacheAura.Spell.DispelType == WoWDispelType.Enrage);
                }
                return true;
            });
        }

        #endregion

        #region BuffHeal

//        private static readonly HashSet<int> BuffHealHS = new HashSet<int>
//            {
//                774, // "Rejuvenation",
//                8936, //"Regrowth",
//                33763, //"Lifebloom",
//                48438, //"Wild Growth",
////"Recuperate",
//                61295, //"Riptide",
//                974, //"Earth Shield",
//                51730, //"Earthliving",
//                139, //"Renew",
//                77485, //"Echo of Light",
//                77489, //"Divine Aegis",
//                48500, //"Living Seed",
////"Blood Shield",
//                115151, //"Renewing Mist",
//                124682, //"Enveloping Mist",
//                115175, //"Soothing Mist",
//                124081, //"Zen Sphere",
//                17, //"Power Word: Shield",
//                33206, //"Pain Suppression",
//                76669, //"Illuminated Healing",
//                20925, //"Sacred Shield"
//                //"Enraged Regeneratione")
//            };
        private static readonly HashSet<int> BuffHealHS = new HashSet<int> { 
            0x306, 0x22e8, 0x83e3, 0xbd36, 0xef6f, 0x3ce, 0xca12, 0x8b, 0x12ead, 0x12eb1, 0xbd74, 0x1c1cf, 0x1e70a, 0x1c1e7, 0x1e4b1, 0x11, 
            0x81b6, 0x12b7d, 0x51bd
         };
        private static bool BuffHeal(WoWUnit target)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && BuffHealHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region DebuffRootCanCloak

        //private static readonly HashSet<int> DebuffRootCanCloakHS = new HashSet<int>
        //    {
        //        96294, //Chains of Ice (Chilblains)
        //        64695, //Earthgrab (Earthgrab Totem)
        //        339, //Entangling Roots
        //        113770, //Entangling Roots (Force of Nature - Balance Treants)
        //        19975, //Entangling Roots (Nature's Grasp)
        //        113275, //Entangling Roots (Symbiosis)
        //        113275, //Entangling Roots (Symbiosis)
        //        19185, //Entrapment
        //        33395, //Freeze
        //        63685, //Freeze (Frozen Power)
        //        122, //Frost Nova
        //        110693, //Frost Nova (Mage)
        //        87194, //Glyph of Mind Blast
        //        111340, //Ice Ward
        //        102359, //Mass Entanglement
        //        123407, //Spinning Fire Blossom
        //        54706, //Venom Web Spray (Silithid)
        //        114404, //Void Tendril's Grasp
        //        4167, //Web (Spider)
        //    };
        private static readonly HashSet<int> DebuffRootCanCloakHS = new HashSet<int> { 
            0x17826, 0xfcb7, 0x153, 0x1bc6a, 0x4e07, 0x1ba7b, 0x1ba7b, 0x4af1, 0x8273, 0xf8c5, 0x7a, 0x1b065, 0x1549a, 0x1b2ec, 0x18fd7, 0x1e20f, 
            0xd5b2, 0x1bee4, 0x1047
         };
        private static bool DebuffRootCanCloak(WoWUnit target)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && DebuffRootCanCloakHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region DebuffCC

        //private static readonly HashSet<int> DebuffCCHS = new HashSet<int>
        //    {
        //        30217, //Adamantite Grenade
        //        89766, //Axe Toss (Felguard/Wrathguard)
        //        90337, //Bad Manner (Monkey)
        //        710, //Banish
        //        113801, //Bash (Force of Nature - Feral Treants)
        //        102795, //Bear Hug
        //        76780, //Bind Elemental
        //        117526, //Binding Shot
        //        2094, //Blind
        //        105421, //Blinding Light
        //        115752, //Blinding Light (Glyph of Blinding Light)
        //        123393, //Breath of Fire (Glyph of Breath of Fire)
        //        126451, //Clash
        //        122242, //Clash (not sure which one is right)
        //        67769, //Cobalt Frag Bomb
        //        118271, //Combustion Impact
        //        33786, //Cyclone
        //        113506, //Cyclone (Symbiosis)
        //        7922, //Charge Stun
        //        119392, //Charging Ox Wave
        //        1833, //Cheap Shot
        //        44572, //Deep Freeze
        //        54786, //Demonic Leap (Metamorphosis)
        //        99, //Disorienting Roar
        //        605, //Dominate Mind
        //        118895, //Dragon Roar
        //        31661, //Dragon's Breath
        //        77505, //Earthquake
        //        5782, //Fear
        //        118699, //Fear
        //        130616, //Fear (Glyph of Fear)
        //        30216, //Fel Iron Bomb
        //        105593, //Fist of Justice
        //        117418, //Fists of Fury
        //        3355, //Freezing Trap
        //        91800, //Gnaw
        //        1776, //Gouge
        //        853, //Hammer of Justice
        //        110698, //Hammer of Justice (Paladin)
        //        51514, //Hex
        //        2637, //Hibernate
        //        88625, //Holy Word: Chastise
        //        119072, //Holy Wrath
        //        5484, //Howl of Terror
        //        22703, //Infernal Awakening
        //        113056, //Intimidating Roar [Cowering in fear] (Warrior)
        //        113004, //Intimidating Roar [Fleeing in fear] (Warrior)
        //        5246, //Intimidating Shout (aoe)
        //        20511, //Intimidating Shout (targeted)
        //        24394, //Intimidation
        //        408, //Kidney Shot
        //        119381, //Leg Sweep
        //        126246, //Lullaby (Crane)
        //        22570, //Maim
        //        115268, //Mesmerize (Shivarra)
        //        5211, //Mighty Bash
        //        91797, //Monstrous Blow (Dark Transformation)
        //        6789, //Mortal Coil
        //        115078, //Paralysis
        //        113953, //Paralysis (Paralytic Poison)
        //        126355, //Paralyzing Quill (Porcupine)
        //        126423, //Petrifying Gaze (Basilisk)
        //        118, //Polymorph
        //        61305, //Polymorph: Black Cat
        //        28272, //Polymorph: Pig
        //        61721, //Polymorph: Rabbit
        //        61780, //Polymorph: Turkey
        //        28271, //Polymorph: Turtle
        //        9005, //Pounce
        //        102546, //Pounce (Incarnation)
        //        64044, //Psychic Horror
        //        8122, //Psychic Scream
        //        113792, //Psychic Terror (Psyfiend)
        //        118345, //Pulverize
        //        107079, //Quaking Palm
        //        13327, //Reckless Charge
        //        115001, //Remorseless Winter
        //        20066, //Repentance
        //        82691, //Ring of Frost
        //        6770, //Sap
        //        1513, //Scare Beast
        //        19503, //Scatter Shot
        //        132412, //Seduction (Grimoire of Sacrifice)
        //        6358, //Seduction (Succubus)
        //        9484, //Shackle Undead
        //        30283, //Shadowfury
        //        132168, //Shockwave
        //        87204, //Sin and Punishment
        //        104045, //Sleep (Metamorphosis)
        //        50519, //Sonic Blast (Bat)
        //        118905, //Static Charge (Capacitor Totem)
        //        56626, //Sting (Wasp)
        //        107570, //Storm Bolt
        //        10326, //Turn Evil
        //        20549, //War Stomp
        //        105771, //Warbringer
        //        19386, //Wyvern Sting
        //        108194, //Asphyxiate
        //    };
        private static readonly HashSet<int> DebuffCCHS = new HashSet<int> { 
            0x7609, 0x15ea6, 0x160e1, 710, 0x1bc89, 0x1918b, 0x12bec, 0x1cb16, 0x82e, 0x19bcd, 0x1c428, 0x1e201, 0x1edf3, 0x1dd82, 0x108b9, 0x1cdff, 
            0x83fa, 0x1bb62, 0x1ef2, 0x1d260, 0x729, 0xae1c, 0xd602, 0x63, 0x25d, 0x1d06f, 0x7bad, 0x12ec1, 0x1696, 0x1cfab, 0x1fe38, 0x7608, 
            0x19c79, 0x1caaa, 0xd1b, 0x16698, 0x6f0, 0x355, 0x1b06a, 0xc93a, 0xa4d, 0x15a31, 0x1d120, 0x156c, 0x58af, 0x1b9a0, 0x1b96c, 0x147e, 
            0x501f, 0x5f4a, 0x198, 0x1d255, 0x1ed26, 0x582a, 0x1c244, 0x145b, 0x16695, 0x1a85, 0x1c186, 0x1bd21, 0x1ed93, 0x1edd7, 0x76, 0xef79, 
            0x6e70, 0xf119, 0xf154, 0x6e6f, 0x232d, 0x19092, 0xfa2c, 0x1fba, 0x1bc80, 0x1ce49, 0x1a247, 0x340f, 0x1c139, 0x4e62, 0x14303, 0x1a72, 
            0x5e9, 0x4c2f, 0x2053c, 0x18d6, 0x250c, 0x764b, 0x20448, 0x154a4, 0x1966d, 0xc557, 0x1d079, 0xdd32, 0x1a432, 0x2856, 0x259d3, 0x5045, 
            0x19d2b, 0x4bba, 0x1a6a2
         };
        private static bool DebuffCC(WoWUnit target)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && DebuffCCHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region DebuffCCDuration

        //private static readonly HashSet<int> DebuffCCDurationHS = new HashSet<int>
        //    {
        //        30217, //Adamantite Grenade
        //        89766, //Axe Toss (Felguard/Wrathguard)
        //        90337, //Bad Manner (Monkey)
        //        710, //Banish
        //        113801, //Bash (Force of Nature - Feral Treants)
        //        102795, //Bear Hug
        //        76780, //Bind Elemental
        //        117526, //Binding Shot
        //        2094, //Blind
        //        105421, //Blinding Light
        //        115752, //Blinding Light (Glyph of Blinding Light)
        //        123393, //Breath of Fire (Glyph of Breath of Fire)
        //        126451, //Clash
        //        122242, //Clash (not sure which one is right)
        //        67769, //Cobalt Frag Bomb
        //        118271, //Combustion Impact
        //        33786, //Cyclone
        //        113506, //Cyclone (Symbiosis)
        //        7922, //Charge Stun
        //        119392, //Charging Ox Wave
        //        1833, //Cheap Shot
        //        44572, //Deep Freeze
        //        54786, //Demonic Leap (Metamorphosis)
        //        99, //Disorienting Roar
        //        605, //Dominate Mind
        //        118895, //Dragon Roar
        //        31661, //Dragon's Breath
        //        77505, //Earthquake
        //        5782, //Fear
        //        118699, //Fear
        //        130616, //Fear (Glyph of Fear)
        //        30216, //Fel Iron Bomb
        //        105593, //Fist of Justice
        //        117418, //Fists of Fury
        //        3355, //Freezing Trap
        //        91800, //Gnaw
        //        1776, //Gouge
        //        853, //Hammer of Justice
        //        110698, //Hammer of Justice (Paladin)
        //        51514, //Hex
        //        2637, //Hibernate
        //        88625, //Holy Word: Chastise
        //        119072, //Holy Wrath
        //        5484, //Howl of Terror
        //        22703, //Infernal Awakening
        //        113056, //Intimidating Roar [Cowering in fear] (Warrior)
        //        113004, //Intimidating Roar [Fleeing in fear] (Warrior)
        //        5246, //Intimidating Shout (aoe)
        //        20511, //Intimidating Shout (targeted)
        //        24394, //Intimidation
        //        408, //Kidney Shot
        //        119381, //Leg Sweep
        //        126246, //Lullaby (Crane)
        //        22570, //Maim
        //        115268, //Mesmerize (Shivarra)
        //        5211, //Mighty Bash
        //        91797, //Monstrous Blow (Dark Transformation)
        //        6789, //Mortal Coil
        //        115078, //Paralysis
        //        113953, //Paralysis (Paralytic Poison)
        //        126355, //Paralyzing Quill (Porcupine)
        //        126423, //Petrifying Gaze (Basilisk)
        //        118, //Polymorph
        //        61305, //Polymorph: Black Cat
        //        28272, //Polymorph: Pig
        //        61721, //Polymorph: Rabbit
        //        61780, //Polymorph: Turkey
        //        28271, //Polymorph: Turtle
        //        9005, //Pounce
        //        102546, //Pounce (Incarnation)
        //        64044, //Psychic Horror
        //        8122, //Psychic Scream
        //        113792, //Psychic Terror (Psyfiend)
        //        118345, //Pulverize
        //        107079, //Quaking Palm
        //        13327, //Reckless Charge
        //        115001, //Remorseless Winter
        //        20066, //Repentance
        //        82691, //Ring of Frost
        //        6770, //Sap
        //        1513, //Scare Beast
        //        19503, //Scatter Shot
        //        132412, //Seduction (Grimoire of Sacrifice)
        //        6358, //Seduction (Succubus)
        //        9484, //Shackle Undead
        //        30283, //Shadowfury
        //        132168, //Shockwave
        //        87204, //Sin and Punishment
        //        104045, //Sleep (Metamorphosis)
        //        50519, //Sonic Blast (Bat)
        //        118905, //Static Charge (Capacitor Totem)
        //        56626, //Sting (Wasp)
        //        107570, //Storm Bolt
        //        10326, //Turn Evil
        //        20549, //War Stomp
        //        105771, //Warbringer
        //        19386, //Wyvern Sting
        //        108194, //Asphyxiate
        //    };
        private static readonly HashSet<int> DebuffCCDurationHS = new HashSet<int> { 
            0x7609, 0x15ea6, 0x160e1, 710, 0x1bc89, 0x1918b, 0x12bec, 0x1cb16, 0x82e, 0x19bcd, 0x1c428, 0x1e201, 0x1edf3, 0x1dd82, 0x108b9, 0x1cdff, 
            0x83fa, 0x1bb62, 0x1ef2, 0x1d260, 0x729, 0xae1c, 0xd602, 0x63, 0x25d, 0x1d06f, 0x7bad, 0x12ec1, 0x1696, 0x1cfab, 0x1fe38, 0x7608, 
            0x19c79, 0x1caaa, 0xd1b, 0x16698, 0x6f0, 0x355, 0x1b06a, 0xc93a, 0xa4d, 0x15a31, 0x1d120, 0x156c, 0x58af, 0x1b9a0, 0x1b96c, 0x147e, 
            0x501f, 0x5f4a, 0x198, 0x1d255, 0x1ed26, 0x582a, 0x1c244, 0x145b, 0x16695, 0x1a85, 0x1c186, 0x1bd21, 0x1ed93, 0x1edd7, 0x76, 0xef79, 
            0x6e70, 0xf119, 0xf154, 0x6e6f, 0x232d, 0x19092, 0xfa2c, 0x1fba, 0x1bc80, 0x1ce49, 0x1a247, 0x340f, 0x1c139, 0x4e62, 0x14303, 0x1a72, 
            0x5e9, 0x4c2f, 0x2053c, 0x18d6, 0x250c, 0x764b, 0x20448, 0x154a4, 0x1966d, 0xc557, 0x1d079, 0xdd32, 0x1a432, 0x2856, 0x259d3, 0x5045, 
            0x19d2b, 0x4bba, 0x1a6a2
         };
        private static bool DebuffCCDuration(WoWUnit target, double duration, bool LogSpell = false)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            AuraCacheClass class2 = (from aura in AuraCacheList
                                     orderby aura.AuraCacheAura.TimeLeft descending
                                     select aura).FirstOrDefault<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && (aura.AuraCacheAura.TimeLeft.TotalMilliseconds > duration)) && DebuffCCDurationHS.Contains(aura.AuraCacheId));
            if (class2 == null)
            {
                return false;
            }
            if (LogSpell)
            {
                Styx.Common.Logging.Write("DebuffCCDuration on {0} {1} SpellID {2} Duration: {3}", new object[] { target.SafeName, class2.AuraCacheAura.Name, class2.AuraCacheId, class2.AuraCacheAura.TimeLeft.TotalMilliseconds });
            }
            return true;
        }

        #endregion

        #region DebuffMagicCCDuration

        //private static readonly HashSet<int> DebuffMagicCCDurationHS = new HashSet<int>
        //    {
        //        710, //Banish
        //        76780, //Bind Elemental
        //        117526, //Binding Shot
        //        105421, //Blinding Light
        //        115752, //Blinding Light (Glyph of Blinding Light)
        //        123393, //Breath of Fire (Glyph of Breath of Fire)
        //        118271, //Combustion Impact
        //        44572, //Deep Freeze
        //        99, //Disorienting Roar
        //        605, //Dominate Mind
        //        31661, //Dragon's Breath
        //        5782, //Fear
        //        118699, //Fear
        //        130616, //Fear (Glyph of Fear)
        //        105593, //Fist of Justice
        //        117418, //Fists of Fury
        //        3355, //Freezing Trap
        //        853, //Hammer of Justice
        //        110698, //Hammer of Justice (Paladin)
        //        2637, //Hibernate
        //        51514, //Hex
        //        88625, //Holy Word: Chastise
        //        119072, //Holy Wrath
        //        5484, //Howl of Terror
        //        126246, //Lullaby (Crane)
        //        115268, //Mesmerize (Shivarra)
        //        6789, //Mortal Coil
        //        118, //Polymorph
        //        61305, //Polymorph: Black Cat
        //        28272, //Polymorph: Pig
        //        61721, //Polymorph: Rabbit
        //        61780, //Polymorph: Turkey
        //        28271, //Polymorph: Turtle
        //        64044, //Psychic Horror
        //        8122, //Psychic Scream
        //        113792, //Psychic Terror (Psyfiend)
        //        107079, //Quaking Palm
        //        115001, //Remorseless Winter
        //        20066, //Repentance
        //        82691, //Ring of Frost
        //        1513, //Scare Beast
        //        19503, //Scatter Shot
        //        132412, //Seduction (Grimoire of Sacrifice)
        //        6358, //Seduction (Succubus)
        //        9484, //Shackle Undead
        //        30283, //Shadowfury
        //        87204, //Sin and Punishment
        //        104045, //Sleep (Metamorphosis)
        //        50519, //Sonic Blast (Bat)
        //        118905, //Static Charge (Capacitor Totem)
        //        10326, //Turn Evil
        //        108194, //Asphyxiate
        //    };
        private static readonly HashSet<int> DebuffMagicCCDurationHS = new HashSet<int> { 
            710, 0x12bec, 0x1cb16, 0x19bcd, 0x1c428, 0x1e201, 0x1cdff, 0xae1c, 0x63, 0x25d, 0x7bad, 0x1696, 0x1cfab, 0x1fe38, 0x19c79, 0x1caaa, 
            0xd1b, 0x355, 0x1b06a, 0xa4d, 0xc93a, 0x15a31, 0x1d120, 0x156c, 0x1ed26, 0x1c244, 0x1a85, 0x76, 0xef79, 0x6e70, 0xf119, 0xf154, 
            0x6e6f, 0xfa2c, 0x1fba, 0x1bc80, 0x1a247, 0x1c139, 0x4e62, 0x14303, 0x5e9, 0x4c2f, 0x2053c, 0x18d6, 0x250c, 0x764b, 0x154a4, 0x1966d, 
            0xc557, 0x1d079, 0x2856, 0x259d3, 0x1a6a2
         };
        private static bool DebuffMagicCCDuration(WoWUnit target, double duration)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => (((aura.AuraCacheUnit == target.Guid) && (aura.AuraCacheAura.TimeLeft.TotalMilliseconds > duration)) && DebuffMagicCCDurationHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region DebuffCCleanseASAP

//        private static readonly HashSet<int> DebuffCCleanseASAPHS = new HashSet<int>
//            {
//                105421, //Blinding Light
//                123393, //Breath of Fire (Glyph of Breath of Fire)
//                44572, //Deep Freeze
//                605, //Dominate Mind
//                31661, //Dragon's Breath
//                5782, // target.Class != WoWClass.Warrior || //Fear
//                118699, // target.Class != WoWClass.Warrior || //Fear
//                130616, // target.Class != WoWClass.Warrior || //Fear (Glyph of Fear)
//                3355, //Freezing Trap
//                853, //Hammer of Justice
//                110698, //Hammer of Justice (Paladin)
//                51514, //Hex
//                2637, //Hibernate
//                88625, //Holy Word: Chastise
//                119072, //Holy Wrath
//                5484, // target.Class != WoWClass.Warrior || //Howl of Terror
//                115268, //Mesmerize (Shivarra)
//                6789, //Mortal Coil
//                115078, //Paralysis
//                113953, //Paralysis (Paralytic Poison)
//                126355, //Paralyzing Quill (Porcupine)
//                118, //Polymorph
//                61305, //Polymorph: Black Cat
//                28272, //Polymorph: Pig
//                61721, //Polymorph: Rabbit
//                61780, //Polymorph: Turkey
//                28271, //Polymorph: Turtle
//                64044, // target.Class != WoWClass.Warrior || //Psychic Horror
//                8122, // target.Class != WoWClass.Warrior || //Psychic Scream
//                113792, // target.Class != WoWClass.Warrior || //Psychic Terror (Psyfiend)
//                107079, //Quaking Palm
//                115001, //Remorseless Winter
//                20066, // target.Class != WoWClass.Warrior || //Repentance
//                82691, //Ring of Frost
//                1513, //Scare Beast
//                132412, //Seduction (Grimoire of Sacrifice)
//                6358, //Seduction (Succubus)
//                9484, //Shackle Undead
//                30283, //Shadowfury
//                87204, //Sin and Punishment
//                104045, //Sleep (Metamorphosis)
//                118905, //Static Charge (Capacitor Totem)
//                10326, //Turn Evil
//                19386, //Wyvern Sting //Thank bp423
//                118552, //Flesh to Stone" //Thank bp423
//                119985, //Dread Spray" //Thank mnipper
//                117436, //Lightning Prison
//                124863, //Visions of Demise
//                123011, //Terrorize (10%)
//                123012, //Terrorize (5%)
////Farraki
//                136708, //Stone Gaze - Thank Clubwar
//                136719, //Blazing Sunlight - Thank Clubwar && bp423
////Gurubashi
//                136587, //Venom Bolt Volley - Thank Clubwar
////Drakaki
//                136710, //Deadly Plague - Thank Clubwar
////Amani
//                136512, //Hex of Confusion - Thank Clubwar
//                136857, //Entrapped - Thank amputations
//                136185, //Fragile Bones - Thank Sk1vvy 
//                136187, //Clouded Mind - Thank Sk1vvy 
//                136183, //Dulled Synapses - Thank Sk1vvy 
//                136181, //Impaired Eyesight - Thank Sk1vvy 
//                138040, //Horrific Visage - Thank macVsog
//                117949, //Closed Curcuit
//                112948, //Frostbomb
//            };

        //private static readonly HashSet<int> DebuffCCleanseASAPHSWarrior = new HashSet<int>
        //    {
        //        5782,
        //        118699,
        //        130616,
        //        64044,
        //        8122,
        //        113792
        //    };
        private static readonly HashSet<int> DebuffCCleanseASAPHSWarrior = new HashSet<int> { 0x1696, 0x1cfab, 0x1fe38, 0xfa2c, 0x1fba, 0x1bc80 };
        private static readonly HashSet<int> DebuffCCleanseASAPPvEHS = new HashSet<int> { 
            0x1cf18, 0x1d4b1, 0x1cabc, 0x1e7bf, 0x1e083, 0x1e084, 0x21604, 0x2160f, 0x2158b, 0x21606, 0x21540, 0x21699, 0x213f9, 0x213fb, 0x213f7, 0x213f5, 
            0x21b38, 0x1ccbd, 0x23736
         };
        private static readonly HashSet<int> DebuffCCleanseASAPPvPHS = new HashSet<int> { 
            0x19bcd, 0x1e201, 0xae1c, 0x25d, 0x7bad, 0x1696, 0x1cfab, 0x1fe38, 0xd1b, 0x355, 0x1b06a, 0xc93a, 0xa4d, 0x15a31, 0x1d120, 0x156c, 
            0x1c244, 0x1a85, 0x1bd21, 0x1ed93, 0x76, 0xef79, 0x6e70, 0xf119, 0xf154, 0x6e6f, 0xfa2c, 0x1fba, 0x1bc80, 0x1a247, 0x1c139, 
            0x4e62, 0x14303, 0x5e9, 0x2053c, 0x18d6, 0x250c, 0x764b, 0x154a4, 0x1966d, 0x1d079, 0x2856, 0x259d3, 0x4bba, 0x1b934
         };
        private static bool DebuffCCleanseASAP(WoWUnit target)
        {
            Func<AuraCacheClass, bool> predicate = null;
            Func<AuraCacheClass, bool> func2 = null;
            Func<AuraCacheClass, bool> func3 = null;
            AuraCacheUpdate(target, false);
            if (InRaid || InProvingGrounds)
            {
                if (predicate == null)
                {
                    predicate = a => (a.AuraCacheUnit == target.Guid) && DebuffCCleanseASAPPvEHS.Contains(a.AuraCacheId);
                }
                return AuraCacheList.Any<AuraCacheClass>(predicate);
            }
            if (target.IsPlayer && (target.Class == WoWClass.Warrior))
            {
                if (func2 == null)
                {
                    func2 = aura => (aura.AuraCacheUnit == target.Guid) && DebuffCCleanseASAPHSWarrior.Contains(aura.AuraCacheId);
                }
                if (AuraCacheList.Any<AuraCacheClass>(func2))
                {
                    return false;
                }
            }
            if (func3 == null)
            {
                func3 = a => ((a.AuraCacheUnit == target.Guid) && (a.AuraCacheAura.TimeLeft.TotalMilliseconds > 3000.0)) && DebuffCCleanseASAPPvPHS.Contains(a.AuraCacheId);
            }
            return AuraCacheList.Any<AuraCacheClass>(func3);
        }
        #endregion

        #region DebuffCCBreakonDamage

        //private static readonly HashSet<int> DebuffCCBreakonDamageHS = new HashSet<int>
        //    {
        //        2094, //Blind
        //        105421, //Blinding Light
        //        99, //Disorienting Roar
        //        31661, //Dragon's Breath
        //        3355, //Freezing Trap
        //        1776, //Gouge
        //        2637, //Hibernate
        //        115268, //Mesmerize (Shivarra)
        //        115078, //Paralysis
        //        113953, //Paralysis (Paralytic Poison)
        //        126355, //Paralyzing Quill (Porcupine)
        //        126423, //Petrifying Gaze (Basilisk)
        //        118, //Polymorph
        //        61305, //Polymorph: Black Cat
        //        28272, //Polymorph: Pig
        //        61721, //Polymorph: Rabbit
        //        61780, //Polymorph: Turkey
        //        28271, //Polymorph: Turtle
        //        20066, //Repentance
        //        6770, //Sap
        //        19503, //Scatter Shot
        //        132412, //Seduction (Grimoire of Sacrifice)
        //        6358, //Seduction (Succubus)
        //        104045, //Sleep (Metamorphosis)
        //        19386, //Wyvern Sting
        //    };
        private static readonly HashSet<int> DebuffCCBreakonDamageHS = new HashSet<int> { 
            0x82e, 0x19bcd, 0x63, 0x7bad, 0xd1b, 0x6f0, 0xa4d, 0x1c244, 0x1c186, 0x1ed93, 0x1edd7, 0x76, 0xef79, 0x6e70, 0xf119, 0xf154, 
            0x6e6f, 0x4e62, 0x1a72, 0x4c2f, 0x2053c, 0x18d6, 0x1966d, 0x4bba
         };
        private static bool DebuffCCBreakonDamage(WoWUnit target)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && DebuffCCBreakonDamageHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region DebuffDisarm

        //private static readonly HashSet<int> DebuffDisarmHS = new HashSet<int>
        //    {
        //        50541, //Clench (Scorpid)
        //        676, //Disarm
        //        118093, //Disarm (Voidwalker/Voidlord)
        //        51722, //Dismantle
        //        117368, //Grapple Weapon
        //        126458, //Grapple Weapon (Monk)
        //        64058, //Psychic Horror
        //        91644, //Snatch (Bird of Prey)
        //    };
        private static readonly HashSet<int> DebuffDisarmHS = new HashSet<int> { 0xc56d, 0x2a4, 0x1cd4d, 0xca0a, 0x1ca78, 0x1edfa, 0xfa3a, 0x165fc };
        private static bool DebuffDisarm(WoWUnit target)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && DebuffDisarmHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region DebuffDoNotHeal

        //internal static readonly HashSet<int> DebuffDoNotHealHS = new HashSet<int>
        //    {
        //        137341, // Beast of Nightmares
        //        137332, // Beast of Nightmares
        //        605, //"Dominate Mind",
        //        33786, //"Cyclone",
        //        123255, //"Dissonance Field",
        //        123184, //"Dissonance Field",
        //        121949, //"Parasitic Growth",
        //        137360, //"Corrupted Healing",
        //        122370, //"Reshape Life"
        //    };
        private static readonly HashSet<int> DebuffDoNotHealHS = new HashSet<int> { 0x2187d, 0x21874, 0x25d, 0x83fa, 0x1e177, 0x1e130, 0x1dc5d, 0x21890, 0x1de02, 0x22e0f, 0x22e10, 0x22e11 };
        private static bool DebuffDoNotHeal(WoWUnit target)
        {
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && DebuffDoNotHealHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region DebuffDoNotCleanse

        //internal static readonly HashSet<int> DebuffDoNotCleanseHS = new HashSet<int>
        //    {
        //        8050, //"Flame Shock",
        //        136184, // "Thick Bones",
        //        136186, //"Clear Mind",
        //        136180, //"Keen Eyesight",
        //        136182, //"Improved Synapses",
        //        30108, //"Unstable Affliction", //Grapple Weapon (Monk)
        //        138609, //"Matter Swap",
        //        138732, //"Ionization",
        //        138733, //"Ionization",
        //        34914, //"Vampiric Touch"
        //    };
        private static readonly HashSet<int> DebuffDoNotCleanseHS = new HashSet<int> { 0x213f8, 0x213fa, 0x213f4, 0x213f6, 0x759c, 0x21d71, 0x21dec, 0x21ded, 0x8862 };
        private static bool DebuffDoNotCleanse(WoWUnit target)
        {
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && DebuffDoNotCleanseHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region DebuffDot

        //private static DateTime DebuffDotLast;

        private static HashSet<WoWApplyAuraType> HS_HasAuraTypeDOT = new HashSet<WoWApplyAuraType>()
            {
                WoWApplyAuraType.PeriodicDamage,
                WoWApplyAuraType.PeriodicDamagePercent,
                WoWApplyAuraType.PeriodicLeech
            };

        //private static HashSet<int> HS_HasAuraDOT = new HashSet<int>()
        //    {
        //        84747, //Deep Insight
        //        84746, //Moderate Insight 
        //        84745, //Shallow Insight
        //        95223, //Mass Resurrected    
        //        71328, //Dungeon Cooldown 
        //        45181, //Cheated Death  
        //        119611, //Renewing Mist 
        //        //118253, //Serpent Sting
        //        118283, //Ursol's Vortex  
        //        53651, //Light's Beacon 
        //        57934, //Tricks of the Trade 
        //        100340, //CSA Area Trigger Dummy Timer
        //        57723, //Exhaustion
        //        57724, //Sated
        //        80354, //Temporal Displacement
        //        25771, //Forbearance
        //        96223, //Run Speed Marker 
        //        95809, //Insanity 
        //        11196, //PeriodicLeech Recently Bandaged 
        //        127973, //CSA Area Trigger Dummy Timer: 
        //    };
        private static readonly HashSet<int> HS_NOTDOT = new HashSet<int> { 
            0x14b0b, 0x14b0a, 0x14b09, 0x173f7, 0x116a0, 0xb07d, 0x1d33b, 0x1ce0b, 0xd193, 0xe24e, 0x187f4, 0xe17b, 0xe17c, 0x139e2, 0x64ab, 0x177df, 
            0x17641, 0x2bbc, 0x1f3e5
         };
        private static bool DebuffDot(WoWUnit target)
        {
            return AuraCacheList.Any<AuraCacheClass>(aura => (((aura.AuraCacheUnit == target.Guid) && aura.AuraCacheAura.IsHarmful) && HS_HasAuraTypeDOT.Contains(aura.AuraCacheAura.ApplyAuraType)));
        }

        private static bool DebuffDotDuration(WoWUnit target, int duration)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => ((((aura.AuraCacheUnit == target.Guid) && (aura.AuraCacheAura.TimeLeft.TotalMilliseconds > duration)) && HS_HasAuraTypeDOT.Contains(aura.AuraCacheAura.ApplyAuraType)) && !HS_NOTDOT.Contains(aura.AuraCacheId)));
        }

        private static double DebuffDotCount(WoWUnit target)
        {
            if (InRaid)
            {
                return 0.0;
            }
            AuraCacheUpdate(target, false);
            return (double)AuraCacheList.Count<AuraCacheClass>(a => (((a.AuraCacheUnit == target.Guid) && !HS_NOTDOT.Contains(a.AuraCacheId)) && HS_HasAuraTypeDOT.Contains(a.AuraCacheAura.ApplyAuraType)));
        }

        #endregion

        #region DebuffFearDuration

        //private static readonly HashSet<int> DebuffFearDurationHS = new HashSet<int>
        //    {
        //        5782, //Fear
        //        118699, //Fear
        //        130616, //Fear (Glyph of Fear)
        //        5484, //Howl of Terror
        //        113056, //Intimidating Roar [Cowering in fear] (Warrior)
        //        113004, //Intimidating Roar [Fleeing in fear] (Warrior)
        //        5246, //Intimidating Shout (aoe)
        //        20511, //Intimidating Shout (targeted)
        //        115268, //Mesmerize (Shivarra)
        //        64044, //Psychic Horror
        //        8122, //Psychic Scream
        //        113792, //Psychic Terror (Psyfiend)
        //        132412, //Seduction (Grimoire of Sacrifice)
        //        6358, //Seduction (Succubus)
        //        87204, //Sin and Punishment
        //        104045 //Sleep (Metamorphosis)
        //    };
        private static readonly HashSet<int> DebuffFearDurationHS = new HashSet<int> { 0x1696, 0x1cfab, 0x1fe38, 0x156c, 0x1b9a0, 0x1b96c, 0x147e, 0x501f, 0x1c244, 0xfa2c, 0x1fba, 0x1bc80, 0x2053c, 0x18d6, 0x154a4, 0x1966d };
        private static bool DebuffFearDuration(WoWUnit target, double duration)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => (((aura.AuraCacheUnit == target.Guid) && (aura.AuraCacheAura.TimeLeft.TotalMilliseconds > duration)) && DebuffFearDurationHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region DebuffRoot

        //private static readonly HashSet<int> DebuffRootHS = new HashSet<int>
        //    {
        //        96294, //Chains of Ice (Chilblains)
        //        116706, //Disable
        //        64695, //Earthgrab (Earthgrab Totem)
        //        339, //Entangling Roots
        //        113770, //Entangling Roots (Force of Nature - Balance Treants)
        //        19975, //Entangling Roots (Nature's Grasp)
        //        113275, //Entangling Roots (Symbiosis)
        //        113275, //Entangling Roots (Symbiosis)
        //        19185, //Entrapment
        //        33395, //Freeze
        //        63685, //Freeze (Frozen Power)
        //        39965, //Frost Grenade
        //        122, //Frost Nova
        //        110693, //Frost Nova (Mage)
        //        55536, //Frostweave Net
        //        87194, //Glyph of Mind Blast
        //        111340, //Ice Ward
        //        45334, //Immobilized (Wild Charge - Bear)
        //        90327, //Lock Jaw (Dog)
        //        102359, //Mass Entanglement
        //        128405, //Narrow Escape
        //        13099, //Net-o-Matic
        //        115197, //Partial Paralysis
        //        50245, //Pin (Crab)
        //        91807, //Shambling Rush (Dark Transformation)
        //        123407, //Spinning Fire Blossom
        //        107566, //Staggering Shout
        //        54706, //Venom Web Spray (Silithid)
        //        114404, //Void Tendril's Grasp
        //        4167, //Web (Spider)
        //    };
        private static readonly HashSet<int> DebuffRootHS = new HashSet<int> { 
            0x17826, 0x1c7e2, 0xfcb7, 0x153, 0x1bc6a, 0x4e07, 0x1ba7b, 0x1ba7b, 0x4af1, 0x8273, 0xf8c5, 0x9c1d, 0x7a, 0x1b065, 0xd8f0, 0x1549a, 
            0x1b2ec, 0xb116, 0x160d7, 0x18fd7, 0x215ba, 0x332b, 0x1c1fd, 0xc445, 0x1669f, 0x1e20f, 0x1a42e, 0xd5b2, 0x1bee4, 0x1047
         };
        private static bool DebuffRoot(WoWUnit target)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && DebuffRootHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region DebuffRootCanCleanse

        //private static readonly HashSet<int> DebuffRootCanCleanseHS = new HashSet<int>
        //    {
        //        96294, //Chains of Ice (Chilblains)
        //        64695, //Earthgrab (Earthgrab Totem)
        //        339, //Entangling Roots
        //        113770, //Entangling Roots (Force of Nature - Balance Treants)
        //        19975, //Entangling Roots (Nature's Grasp)
        //        113275, //Entangling Roots (Symbiosis)
        //        113275, //Entangling Roots (Symbiosis)
        //        19185, //Entrapment
        //        33395, //Freeze
        //        63685, //Freeze (Frozen Power)
        //        122, //Frost Nova
        //        110693, //Frost Nova (Mage)
        //        87194, //Glyph of Mind Blast
        //        111340, //Ice Ward
        //        102359, //Mass Entanglement
        //        115197, //Partial Paralysis
        //        91807, //Shambling Rush (Dark Transformation)
        //        123407, //Spinning Fire Blossom
        //        54706, //Venom Web Spray (Silithid)
        //        //114404, //Void Tendril's Grasp
        //        4167, //Web (Spider)
        //    };
        private static readonly HashSet<int> DebuffRootCanCleanseHS = new HashSet<int> { 
            0x17826, 0xfcb7, 0x153, 0x1bc6a, 0x4e07, 0x1ba7b, 0x1ba7b, 0x4af1, 0x8273, 0xf8c5, 0x7a, 0x1b065, 0x1549a, 0x1b2ec, 0x18fd7, 0x215ba, 
            0x1c1fd, 0x1669f, 0x1e20f, 0xd5b2, 0x1047
         };
        private static bool DebuffRootCanCleanse(WoWUnit target)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && DebuffRootCanCleanseHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region DebuffRootorSnare

        //private static readonly HashSet<int> DebuffRootorSnareHS = new HashSet<int>
        //    {
        //        96294, //Chains of Ice (Chilblains)
        //        116706, //Disable
        //        64695, //Earthgrab (Earthgrab Totem)
        //        339, //Entangling Roots
        //        113770, //Entangling Roots (Force of Nature - Balance Treants)
        //        19975, //Entangling Roots (Nature's Grasp)
        //        113275, //Entangling Roots (Symbiosis)
        //        113275, //Entangling Roots (Symbiosis)
        //        19185, //Entrapment
        //        33395, //Freeze
        //        63685, //Freeze (Frozen Power)
        //        39965, //Frost Grenade
        //        122, //Frost Nova
        //        110693, //Frost Nova (Mage)
        //        55536, //Frostweave Net
        //        87194, //Glyph of Mind Blast
        //        111340, //Ice Ward
        //        45334, //Immobilized (Wild Charge - Bear)
        //        90327, //Lock Jaw (Dog)
        //        102359, //Mass Entanglement
        //        128405, //Narrow Escape
        //        13099, //Net-o-Matic
        //        115197, //Partial Paralysis
        //        50245, //Pin (Crab)
        //        91807, //Shambling Rush (Dark Transformation)
        //        123407, //Spinning Fire Blossom
        //        107566, //Staggering Shout
        //        54706, //Venom Web Spray (Silithid)
        //        114404, //Void Tendril's Grasp
        //        4167, //Web (Spider)
        //        50433, //Ankle Crack (Crocolisk)
        //        110300, //Burden of Guilt
        //        35101, //Concussive Barrage
        //        5116, //Concussive Shot
        //        120, //Cone of Cold
        //        3409, //Crippling Poison
        //        18223, //Curse of Exhaustion
        //        45524, //Chains of Ice
        //        50435, //Chilblains
        //        121288, //Chilled (Frost Armor)
        //        1604, //Dazed
        //        63529, //Dazed - Avenger's Shield
        //        50259, //Dazed (Wild Charge - Cat)
        //        26679, //Deadly Throw
        //        119696, //Debilitation
        //        116095, //Disable
        //        123727, //Dizzying Haze
        //        3600, //Earthbind (Earthbind Totem)
        //        77478, //Earthquake (Glyph of Unstable Earth)
        //        123586, //Flying Serpent Kick
        //        113092, //Frost Bomb
        //        54644, //Frost Breath (Chimaera)
        //        8056, //Frost Shock
        //        116, //Frostbolt
        //        8034, //Frostbrand Attack
        //        44614, //Frostfire Bolt
        //        61394, //Frozen Wake (Glyph of Freezing Trap)
        //        1715, //Hamstring
        //        13810, //Ice Trap
        //        58180, //Infected Wounds
        //        118585, //Leer of the Ox
        //        15407, //Mind Flay
        //        12323, //Piercing Howl
        //        115000, //Remorseless Winter
        //        20170, //Seal of Justice
        //        47960, //Shadowflame
        //        31589, //Slow
        //        129923, //Sluggish (Glyph of Hindering Strikes)
        //        61391, //Typhoon
        //        51490, //Thunderstorm
        //        127797, //Ursol's Vortex
        //        137637, //Warbringer
        //    };
        private static readonly HashSet<int> DebuffRootorSnareHS = new HashSet<int> { 
            0x17826, 0x1c7e2, 0xfcb7, 0x153, 0x1bc6a, 0x4e07, 0x1ba7b, 0x1ba7b, 0x4af1, 0x8273, 0xf8c5, 0x9c1d, 0x7a, 0x1b065, 0xd8f0, 0x1549a, 
            0x1b2ec, 0xb116, 0x160d7, 0x18fd7, 0x215ba, 0x332b, 0x1c1fd, 0xc445, 0x1669f, 0x1e20f, 0x1a42e, 0xd5b2, 0x1bee4, 0x1047, 0xc501, 0x1aedc, 
            0x891d, 0x13fc, 120, 0xd51, 0x472f, 0xb1d4, 0xc503, 0x1d9c8, 0x644, 0xf829, 0xc453, 0x6837, 0x1d390, 0x1c57f, 0x1e34f, 0xe10, 
            0x12ea6, 0x1e2c2, 0x1b9c4, 0xd574, 0x1f78, 0x74, 0x1f62, 0xae46, 0xefd2, 0x6b3, 0x35f2, 0xe344, 0x1cf39, 0x3c2f, 0x3023, 0x1c138, 
            0x4eca, 0xbb58, 0x7b65, 0x1fb83, 0xefcf, 0xc922, 0x1f335, 0x219a5
         };
        private static bool DebuffRootorSnare(WoWUnit target)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            if (UnitHasAura("Hand of Freedom", target))
            {
                return false;
            }
            return AuraCacheList.Any<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && DebuffRootorSnareHS.Contains(aura.AuraCacheId)));
        }

        private static int DebuffRootorSnareCount(WoWUnit target)
        {
            return AuraCacheList.Count<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && DebuffRootorSnareHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region DebuffRootDuration

        private static bool DebuffRootDuration(WoWUnit target, int duration)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            if (UnitHasAura("Hand of Freedom", target))
            {
                return false;
            }
            return AuraCacheList.Any<AuraCacheClass>(aura => (((aura.AuraCacheUnit == target.Guid) && (aura.AuraCacheAura.TimeLeft.TotalMilliseconds > duration)) && DebuffRootHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region DebuffSilence

        //private static readonly HashSet<int> DebuffSilenceHS = new HashSet<int>
        //    {
        //        129597, //Arcane Torrent (Chi)
        //        25046, //Arcane Torrent (Energy)
        //        80483, //Arcane Torrent (Focus)
        //        28730, //Arcane Torrent (Mana)
        //        69179, //Arcane Torrent (Rage)
        //        50613, //Arcane Torrent (Runic Power)
        //        31935, //Avenger's Shield
        //        114238, //Fae Silence (Glyph of Fae Silence)
        //        102051, //Frostjaw (also a root)
        //        1330, //Garrote - Silence
        //        115782, //Optical Blast (Observer)
        //        15487, //Silence
        //        18498, //Silenced - Gag Order
        //        55021, //Silenced - Improved Counterspell
        //        34490, //Silencing Shot
        //        81261, //Solar Beam
        //        113287, //Solar Beam (Symbiosis)
        //        116709, //Spear Hand Strike
        //        24259, //Spell Lock (Felhunter)
        //        132409, //Spell Lock (Grimoire of Sacrifice)
        //        47476, //Strangulate
        //        31117, //Unstable Affliction
        //    };
        private static readonly HashSet<int> DebuffSilenceHS = new HashSet<int> { 
            0x1fa3d, 0x61d6, 0x13a63, 0x703a, 0x10e3b, 0xc5b5, 0x7cbf, 0x1be3e, 0x18ea3, 0x532, 0x1c446, 0x3c7f, 0x4842, 0xd6ed, 0x86ba, 0x13d6d, 
            0x1ba87, 0x1c7e5, 0x5ec3, 0x20539, 0xb974, 0x798d
         };
        private static bool DebuffSilence(WoWUnit target)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && DebuffSilenceHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region DebuffSnare

        //private static readonly HashSet<int> DebuffSnareHS = new HashSet<int>
        //    {
        //        50433, //Ankle Crack (Crocolisk)
        //        110300, //Burden of Guilt
        //        35101, //Concussive Barrage
        //        5116, //Concussive Shot
        //        120, //Cone of Cold
        //        3409, //Crippling Poison
        //        18223, //Curse of Exhaustion
        //        45524, //Chains of Ice
        //        50435, //Chilblains
        //        121288, //Chilled (Frost Armor)
        //        1604, //Dazed
        //        63529, //Dazed - Avenger's Shield
        //        50259, //Dazed (Wild Charge - Cat)
        //        26679, //Deadly Throw
        //        119696, //Debilitation
        //        116095, //Disable
        //        123727, //Dizzying Haze
        //        3600, //Earthbind (Earthbind Totem)
        //        77478, //Earthquake (Glyph of Unstable Earth)
        //        123586, //Flying Serpent Kick
        //        113092, //Frost Bomb
        //        54644, //Frost Breath (Chimaera)
        //        8056, //Frost Shock
        //        116, //Frostbolt
        //        8034, //Frostbrand Attack
        //        44614, //Frostfire Bolt
        //        61394, //Frozen Wake (Glyph of Freezing Trap)
        //        1715, //Hamstring
        //        13810, //Ice Trap
        //        58180, //Infected Wounds
        //        118585, //Leer of the Ox
        //        15407, //Mind Flay
        //        12323, //Piercing Howl
        //        115000, //Remorseless Winter
        //        20170, //Seal of Justice
        //        47960, //Shadowflame
        //        31589, //Slow
        //        129923, //Sluggish (Glyph of Hindering Strikes)
        //        61391, //Typhoon
        //        51490, //Thunderstorm
        //        127797, //Ursol's Vortex
        //        137637, //Warbringer
        //        73682, //Unleash Frost
        //    };
        private static readonly HashSet<int> DebuffSnareHS = new HashSet<int> { 
            0xc501, 0x1aedc, 0x891d, 0x13fc, 120, 0xd51, 0x472f, 0xb1d4, 0xc503, 0x1d9c8, 0x644, 0xf829, 0xc453, 0x6837, 0x1d390, 0x1c57f, 
            0x1e34f, 0xe10, 0x12ea6, 0x1e2c2, 0x1b9c4, 0xd574, 0x1f78, 0x74, 0x1f62, 0xae46, 0xefd2, 0x6b3, 0x35f2, 0xe344, 0x1cf39, 0x3c2f, 
            0x3023, 0x1c138, 0x4eca, 0xbb58, 0x7b65, 0x1fb83, 0xefcf, 0xc922, 0x1f335, 0x219a5, 0x11fd2
         };
        private static bool DebuffSnare(WoWUnit target)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            if (UnitHasAura("Hand of Freedom", target))
            {
                return false;
            }
            return AuraCacheList.Any<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && DebuffSnareHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region DebuffStun

        private static double DebuffStunDurationTimeLeft(WoWUnit target)
        {
            if (InRaid)
            {
                return 0.0;
            }
            AuraCacheUpdate(target, false);
            AuraCacheClass class2 = (from aura in AuraCacheList
                                     orderby aura.AuraCacheAura.TimeLeft descending
                                     select aura).FirstOrDefault<AuraCacheClass>(aura => (aura.AuraCacheUnit == target.Guid) && DebuffStunDurationHS.Contains(aura.AuraCacheId));
            if (class2 == null)
            {
                return 0.0;
            }
            return class2.AuraCacheAura.TimeLeft.TotalMilliseconds;
        }

        private static bool DebuffStun(WoWUnit target)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && DebuffStunDurationHS.Contains(aura.AuraCacheId)));
        }

        //private static readonly HashSet<int> DebuffStunDurationHS = new HashSet<int>
        //    {
        //        89766, //Axe Toss (Felguard/Wrathguard)
        //        113801, //Bash (Force of Nature - Feral Treants)
        //        102795, //Bear Hug
        //        117526, //Binding Shot
        //        126451, //Clash
        //        122242, //Clash (not sure which one is right)
        //        119392, //Charging Ox Wave
        //        1833, //Cheap Shot
        //        44572, //Deep Freeze
        //        54786, //Demonic Leap (Metamorphosis)
        //        105593, //Fist of Justice
        //        117418, //Fists of Fury
        //        91800, //Gnaw
        //        853, //Hammer of Justice
        //        110698, //Hammer of Justice (Paladin)
        //        24394, //Intimidation
        //        408, //Kidney Shot
        //        119381, //Leg Sweep
        //        5211, //Mighty Bash
        //        91797, //Monstrous Blow (Dark Transformation)
        //        9005, //Pounce
        //        102546, //Pounce (Incarnation)
        //        115001, //Remorseless Winter
        //        82691, //Ring of Frost
        //        30283, //Shadowfury
        //        132168, //Shockwave
        //        118905, //Static Charge (Capacitor Totem)
        //        20549, //War Stomp
        //        108194 //Asphyxiate
        //    };
        private static readonly HashSet<int> DebuffStunDurationHS = new HashSet<int> { 
            0x15ea6, 0x1bc89, 0x1918b, 0x1cb16, 0x1edf3, 0x1dd82, 0x1d260, 0x729, 0xae1c, 0xd602, 0x19c79, 0x1caaa, 0x16698, 0x355, 0x1b06a, 0x5f4a, 
            0x198, 0x1d255, 0x145b, 0x16695, 0x232d, 0x19092, 0x1c139, 0x14303, 0x764b, 0x20448, 0x1d079, 0x5045, 0x1a6a2, 0x1bd21
         };
        private static bool DebuffStunDuration(WoWUnit target, double duration)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => (((aura.AuraCacheUnit == target.Guid) && (aura.AuraCacheAura.TimeLeft.TotalMilliseconds > duration)) && DebuffStunDurationHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region DebuffStunFearDuration

        //private static readonly HashSet<int> DebuffStunFearDurationHS = new HashSet<int>
        //    {
        //        119392, //Charging Ox Wave
        //        1833, //Cheap Shot
        //        44572, //Deep Freeze
        //        31661, //Dragon's Breath
        //        77505, //Earthquake
        //        5782, //Fear
        //        118699, //Fear
        //        130616, //Fear (Glyph of Fear)
        //        105593, //Fist of Justice
        //        117418, //Fists of Fury
        //        853, //Hammer of Justice
        //        110698,
        //        113056, //Intimidating Roar [Cowering in fear] (Warrior)
        //        113004, //Intimidating Roar [Fleeing in fear] (Warrior)
        //        5246, //Intimidating Shout (aoe)
        //        20511, //Intimidating Shout (targeted)
        //        24394, //Intimidation
        //        408, //Kidney Shot
        //        119381, //Leg Sweep
        //        5211, //Mighty Bash
        //        91797, //Monstrous Blow (Dark Transformation)
        //        9005, //Pounce
        //        102546, //Pounce (Incarnation)
        //        64044, //Psychic Horror
        //        8122, //Psychic Scream
        //        113792, //Psychic Terror (Psyfiend)
        //        118345, //Pulverize
        //        115001, //Remorseless Winter
        //        82691, //Ring of Frost
        //        30283, //Shadowfury
        //        132168, //Shockwave
        //        87204, //Sin and Punishment
        //        105771, //Warbringer
        //        108194, //Asphyxiate
        //    };
        private static readonly HashSet<int> DebuffStunFearDurationHS = new HashSet<int> { 
            0x1d260, 0x729, 0xae1c, 0x7bad, 0x12ec1, 0x1696, 0x1cfab, 0x1fe38, 0x19c79, 0x1caaa, 0x355, 0x1b06a, 0x1b9a0, 0x1b96c, 0x147e, 0x501f, 
            0x5f4a, 0x198, 0x1d255, 0x145b, 0x16695, 0x232d, 0x19092, 0xfa2c, 0x1fba, 0x1bc80, 0x1ce49, 0x1c139, 0x14303, 0x764b, 0x20448, 0x154a4, 
            0x19d2b, 0x1a6a2
         };
        private static bool DebuffStunFearDuration(WoWUnit target, double duration)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => (((aura.AuraCacheUnit == target.Guid) && (aura.AuraCacheAura.TimeLeft.TotalMilliseconds > duration)) && DebuffStunFearDurationHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region Invulnerable

        //private static readonly HashSet<int> InvulnerableHS = new HashSet<int>
        //    {
        //        //"Bladestorm",
        //        33786, //"Cyclone",
        //        //"Desecrated Ground",
        //        19263, //"Deterrence",
        //        47585, //"Dispersion",
        //        642, //"Divine Shield", //Grapple Weapon (Monk)
        //        45438, //"Ice Block"
        //    };
        private static readonly HashSet<int> InvulnerableHS = new HashSet<int> { 0x83fa, 0x4b3f, 0xb9e1, 0x282, 0xb17e, 0x6cb3 };
        private static bool Invulnerable(WoWUnit target)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && InvulnerableHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region InvulnerablePhysic

        private static bool InvulnerablePhysic(WoWUnit target)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return UnitHasAura(0x3fe, target);
        }

        #endregion

        #region InvulnerableSpell

        //private static readonly HashSet<int> InvulnerableSpellHS = new HashSet<int>
        //    {
        //        48707, //"Anti-Magic Shell",
        //        31224, //"Cloak of Shadows",
        //        115723, //"Glyph of Ice Block",
        //        8178, //"Grounding Totem Effect",
        //        114028, //"Mass Spell Reflection",
        //        23920, //"Spell Reflection",
        //        131523, //"Zen Meditation"
        //    };
        private static readonly HashSet<int> InvulnerableSpellHS = new HashSet<int> { 0xbe43, 0x79f8, 0x1c40b, 0x1ff2, 0x1bd6c, 0x5d70, 0x201c3 };
        private static bool InvulnerableSpell(WoWUnit target)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && InvulnerableSpellHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region InvulnerableRootandSnare

        //private static readonly HashSet<int> InvulnerableRootandSnareHS = new HashSet<int>
        //    {
        //        53271, //"Master's Call",
        //        46924, //"Bladestorm",
        //        1044, //"Hand of Freedom"
        //    };
        private static readonly HashSet<int> InvulnerableRootandSnareHS = new HashSet<int> { 0xd017, 0xb74c, 0x414 };
        private static bool InvulnerableRootandSnare(WoWUnit target)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && InvulnerableRootandSnareHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region InvulnerableStun

        //private static readonly HashSet<int> InvulnerableStunHS = new HashSet<int>
        //    {
        //        48792, //"Icebound Fortitude",
        //        46924, //"Bladestorm"
        //    };
        private static readonly HashSet<int> InvulnerableStunHS = new HashSet<int> { 0xbe98, 0xb74c };
        private static bool InvulnerableStun(WoWUnit target)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return AuraCacheList.Any<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && InvulnerableStunHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region SafeUsingCooldown

        //private static readonly HashSet<int> SafeUsingCooldownHS = new HashSet<int>
        //    {
        //        5277, //"Evasion",
        //        46924, //"Bladestorm",
        //    };
        private static readonly HashSet<int> SafeUsingCooldownHS = new HashSet<int> { 0x149d, 0xb74c };
        private static bool SafeUsingCooldown(WoWUnit target)
        {
            if (InRaid)
            {
                return false;
            }
            AuraCacheUpdate(target, false);
            return !AuraCacheList.Any<AuraCacheClass>(aura => ((aura.AuraCacheUnit == target.Guid) && SafeUsingCooldownHS.Contains(aura.AuraCacheId)));
        }

        #endregion

        #region WriteDebuff

        private static void WriteDebuff(WoWUnit target)
        {
            AuraCacheUpdate(target, false);
            foreach (AuraCacheClass class2 in AuraCacheList)
            {
                if (class2.AuraCacheAura.IsHarmful && (class2.AuraCacheId != 0x20e4f))
                {
                    WoWSpell spell = class2.AuraCacheAura.Spell;
                    Styx.Common.Logging.Write(string.Concat(new object[] { "--------", class2.AuraCacheAura.Name, " (", class2.AuraCacheId, ") (", target.Class, ")--------" }));
                    Styx.Common.Logging.Write("ApplyAuraType: " + class2.AuraCacheAura.ApplyAuraType);
                    Styx.Common.Logging.Write("SpellEffects: " + spell.SpellEffects);
                    Styx.Common.Logging.Write("SpellEffect1: " + spell.SpellEffect1);
                    Styx.Common.Logging.Write("SpellEffect2: " + spell.SpellEffect2);
                    Styx.Common.Logging.Write("SpellEffect3: " + spell.SpellEffect3);
                }
            }
        }

        #endregion
    }
}